<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
div{width:100px;height:50px; background:red;margin-top:50px;font-size:12px;color:green; filter:alpha(opacity:30);opacity:0.3;}
</style>
<script>
window.onload=function(){
	var div=document.getElementsByTagName('div');
	div[0].onmouseover=function(){
		move(this,'width',300)	
	};	
	div[0].onmouseout=function(){
		move(this,'width',100)	
	};	
	div[1].onmouseover=function(){
		move(this,'height',300)	
	};	
	div[1].onmouseout=function(){
		move(this,'height',50)	
	};	
	div[2].onmouseover=function(){
		move(this,'fontSize',20)	
	};	
	div[2].onmouseout=function(){
		move(this,'fontSize',12)	
	};	
	div[3].onmouseover=function(){
		move(this,'opacity',100)	
	};	
	div[3].onmouseout=function(){
		move(this,'opacity',30)	
	};	
};
  function getStyle(obj,attr){
	if(obj.currentStyle){
		return obj.currentStyle[attr];	
	}else{
		return getComputedStyle(obj,false)[attr];	
	};	
}

function move(obj,attr,target){
	clearInterval(obj.timer)
	obj.timer=setInterval(function(){
		var cur=0;
		if(attr=='opacity'){
			cur=parseInt(getStyle(obj,attr)*100)	
		}else{
			cur=parseInt(getStyle(obj,attr));	
		};	
		var speed=(target-cur)/8;
		speed=speed>0?Math.ceil(speed):Math.floor(speed);
		if(target==cur){
			clearInterval(obj.timer)	
		}else{
			if(attr=='opacity'){
				obj.style.filter='alpha:(opacity:'+(cur+speed)+')';
				obj.style.opacity=(cur+speed)/100;
				txt.value=obj.style.opacity;
			}else{
				obj.style[attr]=cur+speed+'px'	
			}	
		};
	},60)
}



</script>
</head>

<body>
<div></div>
<div></div>
<div>ffffffffffff</div>
<div></div>
<input type="text" id="txt" value="" />

</body>
</html>
